<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>会员管理</title>
<style type="text/css">
<!--
body {
	margin-left: 3px;
	margin-top: 0px;
	margin-right: 3px;
	margin-bottom: 0px;
}
.STYLE1 {
	color: #e1e2e3;
	font-size: 12px;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
	color: #344b50;
	font-size: 12px;
}
.STYLE21 {
	font-size: 12px;
	color: #3b6375;
}
.STYLE22 {
	font-size: 12px;
	color: #295568;
}
A:active,A:visited,A:link {
	COLOR: #0629FD;
	TEXT-DECORATION: none
}

A:hover {
	COLOR: #FF6600;
	TEXT-DECORATION: none
}

A.relatelink:active,A.relatelink:visited,A.relatelink:link { 
	color: white;
	TEXT-DECORATION: none
}

A.relatelink:hover {
	COLOR: #FF6600;
	TEXT-DECORATION: none
}

td {
	font-size: 12px;
	color: #003366;
	height:24px
}

.STYLE1 a{
	COLOR: white;
}
.STYLE1 A:active,.STYLE1 A:visited,.STYLE1 A:link {
	COLOR: white;
	TEXT-DECORATION: none
}
.STYLE1 a:hover{
	COLOR: red;
}
.buttom{
	padding:1px 10px;
	font-size:12px;
	border:1px #1E7ACE solid;
	background:#D0F0FF;
}
-->
</style>

<script type="text/javascript">
	function prom(id,index,cardid,name){
		var msg = null;
		if(index == 1){
			msg="消费";
		}else{
			msg="充值";
		}
		var price = prompt("请输入"+ msg +"的金额", "");//将输入的内容赋给变量 name ，
		//这里需要注意的是，prompt有两个参数，前面是提示的话，后面是当对话框出来后，在对话框里的默认值
		var pages = document.getElementById("pages").value;
		if (price){//如果返回的有内容
			if(!isNaN(price)){
				if(index==1){
					price = price * -1;
				}
				if(confirm("确定为卡号【" + cardid + "】姓名【" + name + "】"+ msg + "金额【￥" + Math.abs(price) + "】？")){
					window.location.href = '<%=path%>/user/updateUser.action?id='+id+'&price='+price + '&pages=' + pages;
				}
			}else{
				alert("请填写正确的数字!");
			}
			
		}
	}
	
	function saveUserForm(){
		window.location.href = '<%=path%>/user/saveUserForm.action';
	}
	
	function updateUser(id){
		window.location.href = '<%=path%>/user/updateUserForm.action?id='+id;
	}
	
	function searchNo(){
		var no = document.getElementById("no").value;
		
		if(no){
			window.location.href = '<%=path%>/user/findUserByNo.action?cardno='+no;
		}else{
			alert("请填写卡号!");
		}
	}
	
	function showUser(){
		window.location.href = '<%=path%>/user/showUser.action';
	}
	
	function searchlishiNo(no,name){
		//var no = document.getElementById("lishino").value;
		if(no){
			window.location.href = '<%=path%>/user/lishi.action?cardno='+no + '&name=' + name;
		}else{
			alert("请填写卡号!");
		}
	}
	function cancelUser(id){
		 if(confirm("确认要余额清零吗？清零后该卡状态将变为【新卡】")) {
			 window.location.href = '<%=path%>/user/cancelUser.action?id=' + id;
		}
	}
</script>

</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" ><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="94%" valign="bottom" colspan="2"><h3>会员信息列表</h3></span></td>
              </tr>
            </table></td>
            <!-- 
            <td><div align="right"><span class="STYLE1">
             &nbsp;&nbsp;<img src="images/add.gif" width="10" height="10" /> <a href="#">添加</a>   
             &nbsp;&nbsp;<img src="images/edit.gif" width="10" height="10" /> <a href="#">发布</a>
             &nbsp; <img src="images/del.gif" width="10" height="10" /> <a href="#">删除</a>    &nbsp;&nbsp;   &nbsp;
             </span><span class="STYLE1"> &nbsp;</span></div></td> -->
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
<tr></tr>
  <!-- 查询 -->  	
  		<form action="user/showUser.action" method="post">
  		 <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
  			<tr>
  				<td colspan="5" align="left"  bgcolor="d3eaef" class="STYLE6">信息查询</td>
  			</tr>
  			<tr>
  				<td align="left" bgcolor="#FFFFFF" class="STYLE19">卡号：</td>
  				<td bgcolor="#FFFFFF" class="STYLE19"><input type="text" name="cardno" value="${user.cardno }"></td>
  				<td align="left" bgcolor="#FFFFFF" class="STYLE19">姓名：</td>
  				<td bgcolor="#FFFFFF" class="STYLE19"><input type="text" name="name" value="${user.name }"></td>
  			</tr>
  			<tr>
  				<td align="left" bgcolor="#FFFFFF" class="STYLE19">手机：</td>
  				<td  bgcolor="#FFFFFF" class="STYLE19"><input type="text" name="phone" value="${user.phone }"></td>
  				<td align="left" bgcolor="#FFFFFF" class="STYLE19">身份证：</td>
  				<td bgcolor="#FFFFFF" class="STYLE19"><input type="text" name="idcard" value="${user.idcard }"></td>
  				
  			</tr>
  			<tr>
  				<td colspan="5" bgcolor="#FFFFFF" class="STYLE19"><input type="submit" name="submit" value="查询"></td>
  			</tr>
  		</table>
  		</form>
  		  
  <tr>
    <td>
    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
      <tr>
        <td width="10%" height="20" bgcolor="d3eaef" class="STYLE6" ><div align="left"><span class="STYLE10">卡号</span></div></td>
        <td width="10%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="left"><span class="STYLE10">姓名</span></div></td>
        <td width="3%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="left"><span class="STYLE10">性别</span></div></td>
        <td width="15%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="left"><span class="STYLE10">备注</span></div></td>
        <td width="8%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="right"><span class="STYLE10">余额&nbsp;</span></div></td>
        <td width="3%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="left"><span class="STYLE10">状态</span></div></td>
        <td width="10%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="right"><span class="STYLE10">手机&nbsp;</span></div></td>
        <td width="10%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="left"><span class="STYLE10">微信账号</span></div></td>
        <td width="9%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="right"><span class="STYLE10">开卡日期&nbsp;</span></div></td>
        <td width="25%" height="20" bgcolor="d3eaef" class="STYLE6" colspan="5"><div align="left"><span class="STYLE10">操作</span></div></td>
      </tr>
      <tr>
     
<c:forEach items="${userList}" var="u">
	  <tr>
	   	<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"><a href="user/userDetail.action?id=${u.id }">${u.cardno }</a></div></td>
	   	<td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left">${u.name }</div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"><c:choose><c:when test="${u.sex == 0}">男</c:when><c:otherwise>女</c:otherwise></c:choose></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left">${u.note }</div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="right" style="color:red">￥<fmt:formatNumber value="${u.money }" pattern="##.##" minFractionDigits="2" />&nbsp;</div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"><c:if test="${u.status == 0}">正常</c:if><c:if test="${u.status == 1}">新卡</c:if>&nbsp;</div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="right">${u.phone }&nbsp;</div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left">${u.webchatid }</div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="right"><fmt:formatDate value="${u.date}" pattern="yyyy-MM-dd"/>&nbsp;</div></td>
   		<td bgcolor="#FFFFFF" class="STYLE19" align="left">
   			<span onclick="prom('${u.id }',1,'${u.cardno}','${u.name}');"><input type="button" value="消费" class="buttom" /></span>
   			<span onclick="prom('${u.id }',2,'${u.cardno}','${u.name}');"><input type="button" value="充值" class="buttom" /></span>
   			<span onclick="searchlishiNo('${u.cardno}','${u.name}');"><input type="button" value="查看记录" class="buttom" /></span>
   			<span onclick="updateUser('${u.id }');"><input type="button" value="修改" class="buttom" /></span>
   			<span onclick="cancelUser('${u.id }');"><input type="button" value="余额清零" class="buttom" /></span>
   			
   			<!-- 
   			<span onclick="searchlishiNo('${u.cardno }');"><a href="#">查看记录</a></span> -->
   		</td>
	  </tr>
</c:forEach>   	
   	<!-- 
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><a href="#" title="点击查看和编辑文章">JBPM实例介绍之一</a></div></td>
        <td height="20" bgcolor="#FFFFFF"><div align="center" class="STYLE21">
        <a href="#" title="点击发布文章">发布</a> | 
        <a href="#" title="点击删除文章">删除</a> |
        <a href="#" title="点击编辑文章">编辑</a>
         -->
        </div></td>
      </tr>
    </table>
    
    
    
    </td>
  </tr>
  <tr>
    <td height="30">
    
    <form action="<c:url value='/user/showUser.action'/>">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align=right vAlign="center" noWrap>
        <div align="right"><span align="right" class="STYLE22">&nbsp;&nbsp;&nbsp;&nbsp;共有<strong> ${count }</strong> 条记录
        当前第 <strong>${curPage}</strong>页
        共 <strong>${pageNumber}</strong>页
  <a href="<c:url value='/user/showUser.action?pages=1'/>">第一页</a>
        <c:choose>
			<c:when test="${curPage == 1}">
	    	   	上一页
	    	</c:when>
			<c:otherwise>
				<a href="<c:url value='/user/showUser.action?pages=${curPage-1}'/>">上一页</a>
			</c:otherwise>
		</c:choose>
		转到第<input id="pages"  name="pages"  type="text" value="${curPage}" size="1"/> <input type="submit" class="buttom" value="页" />
		<c:choose>
			<c:when test="${curPage == pageNumber}">
	    	   	下一页
	    	</c:when>
			<c:otherwise>
				<a href="<c:url value='/user/showUser.action?pages=${curPage+1}'/>">下一页</a>
			</c:otherwise>
		</c:choose>
		<a href="<c:url value='/user/showUser.action?pages=${pageNumber}'/>">最后一页</a>
		   ${msg}
  	<c:remove var="msg" scope="session"/>
        </span></div></td>
        
      </tr>
    </table>
    </form>
    </td>
  </tr>
</table>
</body>
</html>

